package cn.tedu.ex;

import java.util.Arrays;
import java.util.Random;

public class Test1 {
    public static void main(String[] args) {
        method();


    }
    public static void method(){
        int[] a=new int[new Random().nextInt(20)];
        System.out.println(a.length);
        for (int i = 0; i <a.length ; i++) {
            a[i]=new Random().nextInt(1000);
        }
        //int[] a={96,85,32,56,18};
        for (int i=0;i<a.length;i++){
            for (int j = i; j <a.length ; j++) {
                if (a[i]>a[j]){
                    int c=a[i];
                    a[i]=a[j];
                    a[j]=c;
                }
            }
        }
        System.out.println(Arrays.toString(a));
    }

    /**
     *
     * @param a
     */
    public static void bubbleSort(int[] a){
        for (int i=0;i<a.length-1;i++){
            for (int j = 0; j <a.length-i-1 ; j++) {
                if (a[j]>a[j+1]){
                    int c=a[j];
                    a[j]=a[j+1];
                    a[j+1]=c;
                }
            }
        }
        System.out.println(Arrays.toString(a));
    }

    /**
     *
     * @param length
     * @return
     */
    public static int[] randomArr(int length){
        int[] a=new int[length];
        for (int i = 0; i <a.length ; i++) {
            a[i]=new Random().nextInt(1000);
        }
        return a;
    }

}
